perf(network): Remove extern and add const to global network variables#2726
perf(network): Remove extern and add const to global network variables#2726Caball009 wants to merge 4 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/GameNetwork/NetworkDefs.h | Converts extern mutable globals and static const to static constexpr const, inlining values for compiler optimization. A relocated comment carries a 2025 date. |
| Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp | Removes the now-redundant global variable definitions for MIN_LOGIC_FRAMES, MAX_FRAMES_AHEAD, MIN_RUNAHEAD, FRAME_DATA_LENGTH, and FRAMES_TO_KEEP, which are now constexpr in the header. |
| Generals/Code/GameEngine/Source/Common/CommandLine.cpp | Removes parseRunAhead function and the -RunAhead command-line parameter registration, consistent with the variables becoming compile-time constants. |
| GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp | Same -RunAhead removal as Generals/; both game variants are updated in sync, addressing the PR TODO. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["NetworkDefs.h\nstatic constexpr const\nMIN_LOGIC_FRAMES = 5\nMAX_FRAMES_AHEAD = 128\nMIN_RUNAHEAD = 4\nFRAME_DATA_LENGTH = (128+1)*2\nFRAMES_TO_KEEP = (128/2)+1"] -->|included by| B["NetworkUtil.cpp\n(definitions removed)"]
A -->|included by| C["Other TUs\n(values inlined at compile time)"]
D["CommandLine.cpp\n(Generals + Zero Hour)"] -->|removed| E["-RunAhead handler\nparseRunAhead()"]
E -.->|"previously mutated (now const)"| A
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
Core/GameEngine/Include/GameNetwork/NetworkDefs.h:35-36
This comment was newly added to the header file and references a date from 2025, which is prior to the current year (2026). Per project convention, newly created comments should use the current year.
```suggestion
// TheSuperHackers @tweak Mauller 26/05/2026 reduce the minimum runahead from 10
// This lets network games run at latencies down to 133ms when the network conditions allow
```
Reviews (3): Last reviewed commit: "Replicated in Generals." | Re-trigger Greptile
This PR removes the "-RunAhead" command line so that a couple of global network variables can be marked
static conststatic constexpr constfor safety and performance. Considering that the "RunAhead" command is for development only and likely rarely used, I think it's ok to get rid of it.The current setup with
externin the header and definition in the source file causes the compiler to miss out on optimizations. It's possible that link time optimization would fix this, but that's not currently used.TODO: